public class Solution {
    public int minCostClimbingStairs(int[] cost) {
        int n = cost.length;
        int[] pb = new int[n + 1];
        //初始化
        pb[0] = 0;
        pb[1] = 0;

        if(n == 0 || n == 1) return 0;

        for(int i = 2; i < n + 1;i++){
            //状态转移方程
            pb[i] = Math.min(pb[i - 1] + cost[i - 1],pb[i - 2] + cost[i - 2]);
        }

        return pb[cost.length];
    }
}
